package com.richardjaap.data;

public class Player {
	
	private RouletteTable table;
	private Account account;
	
	private int id;
	private double cashBuyIn;
	
	public Player(Account account){
		this.account = account;
		this.account.getId();
	}
	
	public Account getAccount(){
		return account;
	}
	
	public void joinTable(int tableId){
		if(account.getCashTotal() != 0){
			table = Lobby.getInstance().getTable(tableId);
			table.addPlayer(this);
		} else
			System.out.println("Your balance is 0. You should top up first.");
	}

	public boolean bet(Bet bet){
		if(bet.getAmount() > account.getCashTotal())
			return false;
		double cashTotal = account.getCashTotal();
		account.setCashTotal(cashTotal -= bet.getAmount());
	    table.placeBet(bet);
		return true;
	}
	
	public RouletteTable getCurrentTable()
	{
		return table;
	}

	public int getId() {
		return id;
	}
	
	public double getCashBuyIn() {
		return cashBuyIn;
	}

	public void setCashBuyIn(double cashBuyIn) {
		this.cashBuyIn = cashBuyIn;
	}
}
